//This file used to set the stock refresh frequency
//
package ck.tool.stocksmart;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class StockRefreshfreq extends Activity implements OnCheckedChangeListener,
                      View.OnClickListener{
	
    private TextView mChoice;
    private RadioGroup mRadioGroup;
    
	@Override
    protected void onCreate(Bundle savedInstanceState) {
    // Be sure to call the super class.
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.refreshfreq);
    
    mRadioGroup = (RadioGroup) findViewById(R.id.menu);
    //
    
    // test listening to checked change events
    String selection = getString(R.string.refresh_selection);
    mRadioGroup.setOnCheckedChangeListener(this);
    mChoice = (TextView) findViewById(R.id.choice);
    mChoice.setText(selection + mRadioGroup.getCheckedRadioButtonId());

    // test clearing the selection
    Button clearButton = (Button) findViewById(R.id.clear);
    clearButton.setOnClickListener(this);
	}

	public void onCheckedChanged(RadioGroup group, int checkedId) {
		String selection = getString(R.string.refresh_selection);
    	String none = getString(R.string.radio_group_none);
    	mChoice.setText(selection +
    		(checkedId == View.NO_ID ? none : checkedId));
	}

	@Override
	public void onClick(View v) {
		mRadioGroup.clearCheck();
	}
    
}